package yealink;

/**
 * Created by lizhenyu on 2019/9/18
 * description
 */

/*后续为参考代码，不影响判题 */
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class MissionTree {
    private List<Task> taskList = new ArrayList<>();

    public void addTask(String id,String name,String parentId) {
        //实现加入任务
        Task task = new Task(id, name, parentId);
        taskList.add(task);
    }
    public void countLevel() {
        //实现对level的计算
    }
    public Task getTask(String taskId){
        //按任务id查找任务
        return null;
    }
    //主函数，基本不用修改，定义了输入输出，重点考核树的整理
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String taskId=null;
        MissionTree tasks=new MissionTree();
        try {
            while(true) {
                String newLine = scan.nextLine();
                if(newLine.startsWith("finish")) {
                    taskId=newLine.substring("finish".length()).trim();
                    break;
                }
                String[] param = newLine.split("\\s+");
                tasks.addTask(param[0], param[1],param.length>2?param[2]:null);
            }
        } finally {
            scan.close();
        }
        tasks.countLevel();
        Task target=null;
        if(taskId !=null) {
            target=tasks.getTask(taskId);
        }
        if(target !=null) {
            System.out.printf("%s %d\n", target.getName(),target.getLevel());
        }
        else {
            System.out.println("nofound");
        }
    }
}
/**
 * 此处只定义了基本属性，如果你认为要增加，可以自行处理。
 */
class Task{
    private String id;
    private String name;
    private String parentId;
    private int level;
    private List<Task> children;
    public Task() {}
    public Task(String id, String name,String parentId) {
        super();
        this.id = id;
        this.name = name;
        this.parentId=parentId ;
    }
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public List<Task> getChildren() {
        return children;
    }

    public void setChildren(List<Task> children) {
        this.children = children;
    }
}